package com.tzbank.common.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.tzbank.common.service.AreaService;
import com.tzbank.utils.CodeUtil;
import com.tzbank.utils.ResultUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
public class AreaController {

	@Autowired
	private AreaService areaService;

	@PostMapping(value = "selectArea")
	public Map<String, Object> selectArea(@RequestBody Map<String, Object> params) {
		try {
			return this.areaService.selectArea(String.valueOf(params.get("id")), Integer.parseInt(params.get("level").toString()));
		} catch (Exception e) {
			log.error("error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}

}
